package com.example.springboot_jxc_0511.jxc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.springboot_jxc_0511.jxc.entity.Sale;
import com.example.springboot_jxc_0511.jxc.mapper.SaleMapper;
import com.example.springboot_jxc_0511.jxc.service.ISaleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author gongxl
 * @since 2021-05-11
 */
@Service
public class SaleServiceImpl extends ServiceImpl<SaleMapper, Sale> implements ISaleService {
    @Autowired
    private SaleMapper saleMapper;
    @Override
    public BigDecimal getQuantity(Sale sale) {
        BigDecimal totalprice = sale.getPrice().multiply(BigDecimal.valueOf(sale.getQuantity())) ;
        return totalprice;
    }

    @Override
    public List<Sale> getSaleListByPage(IPage page, Sale sale) {
        return saleMapper.getSaleListByPage(page,sale);
    }
}
